package filemanager;

import java.io.File;
import java.io.FilenameFilter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class FileNameFilter implements FilenameFilter {

	String starts;
	
	public FileNameFilter(String starts) {
		this.starts = starts;
	}

	public boolean accept(File file, String name) {
				
		Pattern pattern = Pattern.compile("(.*)\\.r.*");

		Matcher matcher = pattern.matcher(name);		  
		
		if(matcher.find() && matcher.group(1).equals(this.starts))
			return true;

		return false;
	}
	
}